package com.itboye.jinpuyiyuan.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.itboye.jinpuyiyuan.R;
import com.itboye.jinpuyiyuan.bean.DateBean;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/12/18 0018.
 */

public class DateRecylerAdapter extends RecyclerView.Adapter<DateRecylerAdapter.MyViewHolder> {
    private ArrayList<DateBean> list;
    private Context context;
    private LayoutInflater inflater;

    public DateRecylerAdapter(Context context,ArrayList<DateBean> list){
        this.context=context;
        this.list=list;
        inflater=LayoutInflater.from(context);
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View inflate = inflater.inflate(R.layout.item_daterecycler, parent, false);
        MyViewHolder myViewHolder = new MyViewHolder(inflate);
        return myViewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.monthTv.setText(list.get(position).getMonth()+"-"+list.get(position).getDay());
        holder.weekTv.setText(list.get(position).getWeek());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        TextView weekTv,monthTv;
        public MyViewHolder(View itemView) {
            super(itemView);
         weekTv = itemView.findViewById(R.id.weekTv);
         monthTv = itemView.findViewById(R.id.monthTv);
        }
    }
}
